package com.reyco1.medusa.core
{
	import flash.events.TimerEvent;
	import flash.utils.Timer;

	public class GlobalTimer
	{
		private static var mainTimer:Timer = new Timer(10);
		
		public static function register(handler:Function):void
		{
			mainTimer.addEventListener(TimerEvent.TIMER, handler, false, 0, true);
			if( !mainTimer.running ) mainTimer.start();
		}
		
		public static function unRegister(handler:Function):void
		{
			mainTimer.removeEventListener(TimerEvent.TIMER, handler);
			if( !mainTimer.hasEventListener(TimerEvent.TIMER) ) mainTimer.stop();
		}
		
		public static function setDelay(delay:int):void
		{
			mainTimer.delay = delay;
		}
	}
}